package com.atguigu.yygh.cmn.exceldemo;

import com.alibaba.excel.EasyExcel;

import java.util.Arrays;
import java.util.List;

/**
 * @author:ahang
 * @create:2022-08-30 23:53
 * @Description:
 */
public class ExcelDemoTest {
    //创建execl文档,并且写入一些数据
    public static void main1(String[] args) {
        Student student = new Student(101, "张三", "北京", 13);
        Student student1 = new Student(102, "李四", "上海", 12);
        Student student2 = new Student(103, "王五", "广州", 15);

        List<Student> students = Arrays.asList(student, student1, student2);

        String path = "C:\\Users\\周航宇\\Desktop\\学生列表.xlsx";

        EasyExcel.write(path,Student.class)
                .sheet("尚硅谷学生列表")
                .doWrite(students);
    }

    //读取execl文档数据
    public static void main(String[] args) {
        String path = "C:\\Users\\周航宇\\Desktop\\学生列表.xlsx";

        EasyExcel.read(path,Student.class,new ExcelReadListener())
                .sheet("尚硅谷学生列表")
                .doRead();
    }
}
